package com.lkd.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lkd.dto.UserDto;
import com.lkd.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lkd.vo.UserVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zzy
 * @since 2025-10-10
 */
public interface UserMapper extends BaseMapper<User> {

    /**
     * 根据用户名查询用户信息
     */
    @Select("SELECT u.*, r.role_code as role_label FROM tb_user u LEFT JOIN tb_role r ON u.role_id = r.role_id WHERE u.user_name = #{username}")
    User selectByLoginName(String loginName);

    /**
     * 人员搜索
     * @param page
     * @param userDto
     * @return
     */
    Page<UserVo> search(@Param("page") Page<User> page, @Param("userDto") UserDto userDto);

//    <select id="selectByLoginName" resultType="com.lkd.entity.User">
//    select * from tb_user where loginname = #{loginname}
//    </select>
}
